package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.FieldConvert;
import com.nbsaas.boot.code.annotation.FieldName;
import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;


@EqualsAndHashCode(callSuper = true)
@Comment("商品文件")
@Data
@FormAnnotation(title = "商品文件", model = "商品文件", showSelect = true)
@Entity
@Table(name = "nb_product_file")
public class ProductFile extends LongEntity {


    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private Product product;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "图片"),
                    @DictItem(value = 2, label = "视频"),
                    @DictItem(value = 3, label = "文件"),
            }
    )
    @Comment("文件类型 1图片，2视频，3文件")
    private Integer fileType;


    @Comment("文件地址")
    private String url;

}
